package game_elements_layer.guys_stuff.guys_actions;

import game_elements_layer.guys_stuff.Guys;
import game_elements_layer.field_stuff.locations_stuff.Locations;
import game_elements_layer.field_stuff.locations_stuff.NotNearblyLocationException;

/**
 * Created by vych0914 on 06.10.2014.
 */
public class GuysMoveAction extends GuysActions {
    private Guys guy;
    private Locations destination;

    public GuysMoveAction(Guys guy, Locations destination) throws NotNearblyLocationException {
        if (!guy.getCurrentLocation().getNearbyLocations().contains(destination))
            throw new NotNearblyLocationException("exception rised while guy in " + guy.getCurrentLocation() + " tried to go to location " + destination);
        this.guy = guy;
        this.destination = destination;
    }

    @Override
    public void perform() {
        this.guy.setCurrentLocation(destination);
    }
}
